package com.sto.stoapp.entity;

import android.annotation.SuppressLint;
import android.os.Parcel;
import android.os.Parcelable;

import com.sto.stoapp.http.BaseMessage;

/**
 * 问题件实体类
 * 
 * @author mgf
 * 
 */
@SuppressLint("ParcelCreator")
public class ProblemEntity extends BaseEntity implements Parcelable {
	//id
	private String id;
	private String version;
	// 类别编号
	private String typeCode;
	// 类别名称
	private String typeName;
	// 原因编号
	private String reasonCode;
	// 原因详情
	private String reasonDetail;
	// 使用界面
	private String userWidget;
	// 查询语句
	private String sql;
	// 查询参数
	private static String[] sqlField;
	
	public ProblemEntity(){
		
	}

	public ProblemEntity(String responseDetail) {
		String[] data = responseDetail.split((BaseMessage.SPILTE
				+ BaseMessage.SEPARATOR));
		if (data.length > 0) {
			typeCode = data[0].trim();
		}
		if (data.length > 1) {
			typeName = data[1].trim();
		}
		if (data.length > 2) {
			reasonCode = data[2].trim();
		}
		if (data.length > 3) {
			reasonDetail = data[3].trim();
		}
		if (data.length > 4) {
			userWidget = data[4].trim();
		}
	}

	public String getTypeCode() {
		return typeCode;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public void setTypeCode(String typeCode) {
		this.typeCode = typeCode;
	}

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	public String getReasonCode() {
		return reasonCode;
	}

	public void setReasonCode(String reasonCode) {
		this.reasonCode = reasonCode;
	}

	public String getReasonDetail() {
		return reasonDetail;
	}

	public void setReasonDetail(String reasonDetail) {
		this.reasonDetail = reasonDetail;
	}

	public String getUserWidget() {
		return userWidget;
	}

	public void setUserWidget(String userWidget) {
		this.userWidget = userWidget;
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(typeCode);
		dest.writeString(typeName);
		dest.writeString(reasonCode);
		dest.writeString(reasonDetail);
		dest.writeString(userWidget);
		dest.writeString(sql);
		dest.writeStringArray(sqlField);
	}
	
	public static final Parcelable.Creator<ProblemEntity> CREATOR = new Creator<ProblemEntity>() {

		@Override
		public ProblemEntity[] newArray(int size) {
			return new ProblemEntity[size];
		}

		@SuppressWarnings("static-access")
		@Override
		public ProblemEntity createFromParcel(Parcel source) {
			ProblemEntity entity = new ProblemEntity();
			entity.typeCode = source.readString();
			entity.typeName = source.readString();
			entity.reasonCode = source.readString();
			entity.reasonDetail = source.readString();
			entity.userWidget = source.readString();
			entity.sql = source.readString();
			source.readStringArray(entity.sqlField);
			return entity;
		}
	};

	/**
	 * 设置查询的sql语句
	 * @param sql
	 */
	public void setSelectSql(String sql){
		this.sql = sql;
	}
	
	/**
	 * 获取查询的sql语句
	 * @return
	 */
	public String getSelectSql(){
		return sql;
	}
	
	/**
	 * 设置查询的sql语句字段
	 * @param arg
	 */
	public void setSelectField(String[] arg){
		sqlField = arg;
	}
	
	/**
	 * 获取查询的sql语句字段
	 * @return
	 */
	public String[] getSelectField(){
		return sqlField;	
	}
	
	
}
